Search Client Context on Online Social Networks

ABSTRACT

In one embodiment, a method includes receiving, from a client system, a query inputted by a first user at a search client, the search client being associated with context data from a page associated with the search client. The context data identifies: a type of the page associated with the search client, a social context of the page associated with the search client, and a threshold number of search results for display. The method includes identifying one or more entities matching the query and ranking each of the identified entities based at least in part on the social context and the type of the page associated with the search client. The method includes sending, to the client system, instructions for presenting a search-results interface including the threshold number of search results corresponding to the threshold number of top ranking identified entities.

PRIORITY

This application is a continuation under 35 U.S.C. §120 of U.S. patentapplication Ser. No. 14/284,318, filed 21 May 2014.

TECHNICAL FIELD

This disclosure generally relates to social graphs and performingsearches for objects within a social-networking environment.

BACKGROUND

A social-networking system, which may include a social-networkingwebsite, may enable its users (such as persons or organizations) tointeract with it and with each other through it. The social-networkingsystem may, with input from a user, create and store in thesocial-networking system a user profile associated with the user. Theuser profile may include demographic information, communication-channelinformation, and information on personal interests of the user. Thesocial-networking system may also, with input from a user, create andstore a record of relationships of the user with other users of thesocial-networking system, as well as provide services (e.g. wall posts,photo-sharing, event organization, messaging, games, or advertisements)to facilitate social interaction between or among users.

The social-networking system may transmit over one or more networkscontent or messages related to its services to a mobile or othercomputing device of a user. A user may also install softwareapplications on a mobile or other computing device of the user foraccessing a user profile of the user and other data within thesocial-networking system. The social-networking system may generate apersonalized set of content objects to display to a user, such as anewsfeed of aggregated stories of other users connected to the user.

Social-graph analysis views social relationships in terms of networktheory consisting of nodes and edges. Nodes represent the individualactors within the networks, and edges represent the relationshipsbetween the actors. The resulting graph-based structures are often verycomplex. There can be many types of nodes and many types of edges forconnecting nodes. In its simplest form, a social graph is a map of allof the relevant edges between all the nodes being studied.

SUMMARY OF PARTICULAR EMBODIMENTS

In particular embodiments, a social-networking system may receive asearch query from a user via a search client associated with a page orother content. The search techniques described herein can improve asearch query by generating a rewritten query command based on searchcontext data extracted from the page or from other content at which theuser inputs the query. The re-written query may expand the search toidentify users who are related to the querying user or to the searchcontext data in some way, e.g., by being friends of friends of thequerying user. The search client can generate the search context data byextracting signals from the page or other type of content associatedwith the search client. The signals may be data items included in thepage in a structured format. The signals may include social contextdata, such as an owner of the content or page, commenters, tags,comments, likes, and so on. The query can then be rewritten to expandthe search to objects identified by the signals, such as users who havecommented on posts on the page. The search results can also be ranked byrelevance to the user and the page by using the signals as features inmachine-learning ranking techniques.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 illustrates an example network environment associated with asocial-networking system.

FIG. 2 illustrates an example social graph.

FIG. 3A illustrates an example webpage of an online social network.

FIG. 3B illustrate an example user interface (UI) on a mobile clientsystem.

FIG. 4 illustrates an example search query pipeline.

FIG. 5 illustrates an example UI with search results.

FIG. 6 illustrates an example method for optimizing search results basedon contextual information.

FIG. 7 illustrates an example computer system.

DESCRIPTION OF EXAMPLE EMBODIMENTS System Overview

FIG. 1 illustrates an example network environment 100 associated with asocial-networking system. Network environment 100 includes a clientsystem 130, a social-networking system 160, and a third-party system 170connected to each other by a network 110. Although FIG. 1 illustrates aparticular arrangement of client system 130, social-networking system160, third-party system 170, and network 110, this disclosurecontemplates any suitable arrangement of client system 130,social-networking system 160, third-party system 170, and network 110.As an example and not by way of limitation, two or more of client system130, social-networking system 160, and third-party system 170 may beconnected to each other directly, bypassing network 110. As anotherexample, two or more of client system 130, social-networking system 160,and third-party system 170 may be physically or logically co-locatedwith each other in whole or in part. Moreover, although FIG. 1illustrates a particular number of client systems 130, social-networkingsystems 160, third-party systems 170, and networks 110, this disclosurecontemplates any suitable number of client systems 130,social-networking systems 160, third-party systems 170, and networks110. As an example and not by way of limitation, network environment 100may include multiple client system 130, social-networking systems 160,third-party systems 170, and networks 110.

This disclosure contemplates any suitable network 110. As an example andnot by way of limitation, one or more portions of network 110 mayinclude an ad hoc network, an intranet, an extranet, a virtual privatenetwork (VPN), a local area network (LAN), a wireless LAN (WLAN), a widearea network (WAN), a wireless WAN (WWAN), a metropolitan area network(MAN), a portion of the Internet, a portion of the Public SwitchedTelephone Network (PSTN), a cellular telephone network, or a combinationof two or more of these. Network 110 may include one or more networks110.

Links 150 may connect client system 130, social-networking system 160,and third-party system 170 to communication network 110 or to eachother. This disclosure contemplates any suitable links 150. Inparticular embodiments, one or more links 150 include one or morewireline (such as for example Digital Subscriber Line (DSL) or Data OverCable Service Interface Specification (DOC SIS)), wireless (such as forexample Wi-Fi or Worldwide Interoperability for Microwave Access(WiMAX)), or optical (such as for example Synchronous Optical Network(SONET) or Synchronous Digital Hierarchy (SDH)) links. In particularembodiments, one or more links 150 each include an ad hoc network, anintranet, an extranet, a VPN, a LAN, a WLAN, a WAN, a WWAN, a MAN, aportion of the Internet, a portion of the PSTN, a cellulartechnology-based network, a satellite communications technology-basednetwork, another link 150, or a combination of two or more such links150. Links 150 need not necessarily be the same throughout networkenvironment 100. One or more first links 150 may differ in one or morerespects from one or more second links 150.

In particular embodiments, client system 130 may be an electronic deviceincluding hardware, software, or embedded logic components or acombination of two or more such components and capable of carrying outthe appropriate functionalities implemented or supported by clientsystem 130. As an example and not by way of limitation, a client system130 may include a computer system such as a desktop computer, notebookor laptop computer, netbook, a tablet computer, e-book reader, GPSdevice, camera, personal digital assistant (PDA), handheld electronicdevice, cellular telephone, smartphone, other suitable electronicdevice, or any suitable combination thereof. This disclosurecontemplates any suitable client systems 130. A client system 130 mayenable a network user at client system 130 to access network 110. Aclient system 130 may enable its user to communicate with other users atother client systems 130.

In particular embodiments, client system 130 may include a web browser132, such as MICROSOFT INTERNET EXPLORER, GOOGLE CHROME or MOZILLAFIREFOX, and may have one or more add-ons, plug-ins, or otherextensions, such as TOOLBAR or YAHOO TOOLBAR. A user at client system130 may enter a Uniform Resource Locator (URL) or other addressdirecting the web browser 132 to a particular server (such as server162, or a server associated with a third-party system 170), and the webbrowser 132 may generate a Hyper Text Transfer Protocol (HTTP) requestand communicate the HTTP request to server. The server may accept theHTTP request and communicate to client system 130 one or more Hyper TextMarkup Language (HTML) files responsive to the HTTP request. Clientsystem 130 may render a webpage based on the HTML files from the serverfor presentation to the user. This disclosure contemplates any suitablewebpage files. As an example and not by way of limitation, webpages mayrender from HTML files, Extensible Hyper Text Markup Language (XHTML)files, or Extensible Markup Language (XML) files, according toparticular needs. Such pages may also execute scripts such as, forexample and without limitation, those written in JAVASCRIPT, JAVA,MICROSOFT SILVERLIGHT, combinations of markup language and scripts suchas AJAX (Asynchronous JAVASCRIPT and XML), and the like. Herein,reference to a webpage encompasses one or more corresponding webpagefiles (which a browser may use to render the webpage) and vice versa,where appropriate.

In particular embodiments, social-networking system 160 may be anetwork-addressable computing system that can host an online socialnetwork. Social-networking system 160 may generate, store, receive, andtransmit social-networking data, such as, for example, user-profiledata, concept-profile data, social-graph information, or other suitabledata related to the online social network. Social-networking system 160may be accessed by the other components of network environment 100either directly or via network 110. In particular embodiments,social-networking system 160 may include one or more servers 162. Eachserver 162 may be a unitary server or a distributed server spanningmultiple computers or multiple datacenters. Servers 162 may be ofvarious types, such as, for example and without limitation, web server,news server, mail server, message server, advertising server, fileserver, application server, exchange server, database server, proxyserver, another server suitable for performing functions or processesdescribed herein, or any combination thereof. In particular embodiments,each server 162 may include hardware, software, or embedded logiccomponents or a combination of two or more such components for carryingout the appropriate functionalities implemented or supported by server162. In particular embodiments, social-networking system 164 may includeone or more data stores 164. Data stores 164 may be used to storevarious types of information. In particular embodiments, the informationstored in data stores 164 may be organized according to specific datastructures. In particular embodiments, each data store 164 may be arelational database. Particular embodiments may provide interfaces thatenable a client system 130, a social-networking system 160, or athird-party system 170 to manage, retrieve, modify, add, or delete, theinformation stored in data store 164.

In particular embodiments, social-networking system 160 may store one ormore social graphs in one or more data stores 164. In particularembodiments, a social graph may include multiple nodes—which may includemultiple user nodes (each corresponding to a particular user) ormultiple concept nodes (each corresponding to a particular concept)—andmultiple edges connecting the nodes. Social-networking system 160 mayprovide users of the online social network the ability to communicateand interact with other users. In particular embodiments, users may jointhe online social network via social-networking system 160 and then addconnections (i.e., relationships) to a number of other users ofsocial-networking system 160 whom they want to be connected to. Herein,the term “friend” may refer to any other user of social-networkingsystem 160 with whom a user has formed a connection, association, orrelationship via social-networking system 160.

In particular embodiments, social-networking system 160 may provideusers with the ability to take actions on various types of items orobjects, supported by social-networking system 160. As an example andnot by way of limitation, the items and objects may include groups orsocial networks to which users of social-networking system 160 maybelong, events or calendar entries in which a user might be interested,computer-based applications that a user may use, transactions that allowusers to buy or sell items via the service, interactions withadvertisements that a user may perform, or other suitable items orobjects. A user may interact with anything that is capable of beingrepresented in social-networking system 160 or by an external system ofthird-party system 170, which is separate from social-networking system160 and coupled to social-networking system 160 via a network 110.

In particular embodiments, social-networking system 160 may be capableof linking a variety of entities. As an example and not by way oflimitation, social-networking system 160 may enable users to interactwith each other as well as receive content from third-party systems 170or other entities, or to allow users to interact with these entitiesthrough an application programming interfaces (API) or othercommunication channels.

In particular embodiments, a third-party system 170 may include one ormore types of servers, one or more data stores, one or more interfaces,including but not limited to APIs, one or more web services, one or morecontent sources, one or more networks, or any other suitable components,e.g., that servers may communicate with. A third-party system 170 may beoperated by a different entity from an entity operatingsocial-networking system 160. In particular embodiments, however,social-networking system 160 and third-party systems 170 may operate inconjunction with each other to provide social-networking services tousers of social-networking system 160 or third-party systems 170. Inthis sense, social-networking system 160 may provide a platform, orbackbone, which other systems, such as third-party systems 170, may useto provide social-networking services and functionality to users acrossthe Internet.

In particular embodiments, a third-party system 170 may include athird-party content object provider. A third-party content objectprovider may include one or more sources of content objects, which maybe communicated to a client system 130. As an example and not by way oflimitation, content objects may include information regarding things oractivities of interest to the user, such as, for example, movie showtimes, movie reviews, restaurant reviews, restaurant menus, productinformation and reviews, or other suitable information. As anotherexample and not by way of limitation, content objects may includeincentive content objects, such as coupons, discount tickets, giftcertificates, or other suitable incentive objects.

In particular embodiments, social-networking system 160 also includesuser-generated content objects, which may enhance a user's interactionswith social-networking system 160. User-generated content may includeanything a user can add, upload, send, or “post” to social-networkingsystem 160. As an example and not by way of limitation, a usercommunicates posts to social-networking system 160 from a client system130. Posts may include data such as status updates or other textualdata, location information, photos, videos, links, music or othersimilar data or media. Content may also be added to social-networkingsystem 160 by a third-party through a “communication channel,” such as anewsfeed or stream.

In particular embodiments, social-networking system 160 may include avariety of servers, sub-systems, programs, modules, logs, and datastores. In particular embodiments, social-networking system 160 mayinclude one or more of the following: a web server, action logger,API-request server, relevance-and-ranking engine, content-objectclassifier, notification controller, action log,third-party-content-object-exposure log, inference module,authorization/privacy server, search module, ad-targeting module,user-interface module, user-profile store, connection store, third-partycontent store, or location store. Social-networking system 160 may alsoinclude suitable components such as network interfaces, securitymechanisms, load balancers, failover servers,management-and-network-operations consoles, other suitable components,or any suitable combination thereof. In particular embodiments,social-networking system 160 may include one or more user-profile storesfor storing user profiles. A user profile may include, for example,biographic information, demographic information, behavioral information,social information, or other types of descriptive information, such aswork experience, educational history, hobbies or preferences, interests,affinities, or location. Interest information may include interestsrelated to one or more categories. Categories may be general orspecific. As an example and not by way of limitation, if a user “likes”an article about a brand of shoes the category may be the brand, or thegeneral category of “shoes” or “clothing.” A connection store may beused for storing connection information about users. The connectioninformation may indicate users who have similar or common workexperience, group memberships, hobbies, educational history, or are inany way related or share common attributes. The connection informationmay also include user-defined connections between different users andcontent (both internal and external). A web server may be used forlinking social-networking system 160 to one or more client systems 130or one or more third-party system 170 via network 110. The web servermay include a mail server or other messaging functionality for receivingand routing messages between social-networking system 160 and one ormore client systems 130. An API-request server may allow a third-partysystem 170 to access information from social-networking system 160 bycalling one or more APIs. An action logger may be used to receivecommunications from a web server about a user's actions on or offsocial-networking system 160. In conjunction with the action log, athird-party-content-object log may be maintained of user exposures tothird-party-content objects. A notification controller may provideinformation regarding content objects to a client system 130.Information may be pushed to a client system 130 as notifications, orinformation may be pulled from client system 130 responsive to a requestreceived from client system 130. Authorization servers may be used toenforce one or more privacy settings of the users of social-networkingsystem 160. A privacy setting of a user determines how particularinformation associated with a user can be shared. The authorizationserver may allow users to opt in or opt out of having their actionslogged by social-networking system 160 or shared with other systems(e.g., third-party system 170), such as, for example, by settingappropriate privacy settings. Third-party-content-object stores may beused to store content objects received from third parties, such as athird-party system 170. Location stores may be used for storing locationinformation received from client systems 130 associated with users.Ad-pricing modules may combine social information, the current time,location information, or other suitable information to provide relevantadvertisements, in the form of notifications, to a user.

Social Graphs

FIG. 2 illustrates example social graph 200. In particular embodiments,social-networking system 160 may store one or more social graphs 200 inone or more data stores. In particular embodiments, social graph 200 mayinclude multiple nodes—which may include multiple user nodes 202 ormultiple concept nodes 204—and multiple edges 206 connecting the nodes.Example social graph 200 illustrated in FIG. 2 is shown, for didacticpurposes, in a two-dimensional visual map representation. In particularembodiments, a social-networking system 160, client system 130, orthird-party system 170 may access social graph 200 and relatedsocial-graph information for suitable applications. The nodes and edgesof social graph 200 may be stored as data objects, for example, in adata store (such as a social-graph database). Such a data store mayinclude one or more searchable or queryable indexes of nodes or edges ofsocial graph 200.

In particular embodiments, a user node 202 may correspond to a firstuser of social-networking system 160. As an example and not by way oflimitation, a user may be an individual (human user), an entity (e.g.,an enterprise, business, or third-party application), or a group (e.g.,of individuals or entities) that interacts or communicates with or oversocial-networking system 160. In particular embodiments, when a firstuser registers for an account with social-networking system 160,social-networking system 160 may create a first user node 202corresponding to the user, and store the user node 202 in one or moredata stores. Users and user nodes 202 described herein may, whereappropriate, refer to registered users and user nodes 202 associatedwith registered users. In addition or as an alternative, users and usernodes 202 described herein may, where appropriate, refer to users thathave not registered with social-networking system 160. In particularembodiments, a user node 202 may be associated with information providedby a user or information gathered by various systems, includingsocial-networking system 160. As an example and not by way oflimitation, a user may provide his or her name, profile picture, contactinformation, birth date, sex, marital status, family status, employment,education background, preferences, interests, or other demographicinformation. In particular embodiments, a user node 202 may beassociated with one or more data objects corresponding to informationassociated with a user. In particular embodiments, a user node 202 maycorrespond to one or more webpages.

In particular embodiments, a concept node 204 may correspond to aconcept. As an example and not by way of limitation, a concept maycorrespond to a place (such as, for example, a movie theater,restaurant, landmark, or city); a website (such as, for example, awebsite associated with social-networking system 160 or a third-partywebsite associated with a web-application server); an entity (such as,for example, a person, business, group, sports team, or celebrity); aresource (such as, for example, an audio file, video file, digitalphoto, text file, structured document, or application) which may belocated within social-networking system 160 or on an external server,such as a web-application server; real or intellectual property (suchas, for example, a sculpture, painting, movie, game, song, idea,photograph, or written work); a game; an activity; an idea or theory;another suitable concept; or two or more such concepts. A concept node204 may be associated with information of a concept provided by a useror information gathered by various systems, including social-networkingsystem 160. As an example and not by way of limitation, information of aconcept may include a name or a title; one or more images (e.g., animage of the cover page of a book); a location (e.g., an address or ageographical location); a website (which may be associated with a URL);contact information (e.g., a phone number or an email address); othersuitable concept information; or any suitable combination of suchinformation. In particular embodiments, a concept node 204 may beassociated with one or more data objects corresponding to informationassociated with concept node 204. In particular embodiments, a conceptnode 204 may correspond to one or more webpages.

In particular embodiments, a node in social graph 200 may represent orbe represented by a webpage (which may be referred to as a “profilepage”). Profile pages may be hosted by or accessible tosocial-networking system 160. Profile pages may also be hosted onthird-party websites associated with a third-party server 170. As anexample and not by way of limitation, a profile page corresponding to aparticular external webpage may be the particular external webpage andthe profile page may correspond to a particular concept node 204.Profile pages may be viewable by all or a selected subset of otherusers. As an example and not by way of limitation, a user node 202 mayhave a corresponding user-profile page in which the corresponding usermay add content, make declarations, or otherwise express himself orherself. As another example and not by way of limitation, a concept node204 may have a corresponding concept-profile page in which one or moreusers may add content, make declarations, or express themselves,particularly in relation to the concept corresponding to concept node204.

In particular embodiments, a concept node 204 may represent athird-party webpage or resource hosted by a third-party system 170. Thethird-party webpage or resource may include, among other elements,content, a selectable or other icon, or other inter-actable object(which may be implemented, for example, in JavaScript, AJAX, or PHPcodes) representing an action or activity. As an example and not by wayof limitation, a third-party webpage may include a selectable icon suchas “like,” “check in,” “eat,” “recommend,” or another suitable action oractivity. A user viewing the third-party webpage may perform an actionby selecting one of the icons (e.g., “eat”), causing a client system 130to transmit to social-networking system 160 a message indicating theuser's action. In response to the message, social-networking system 160may create an edge (e.g., an “eat” edge) between a user node 202corresponding to the user and a concept node 204 corresponding to thethird-party webpage or resource and store edge 206 in one or more datastores.

In particular embodiments, a pair of nodes in social graph 200 may beconnected to each other by one or more edges 206. An edge 206 connectinga pair of nodes may represent a relationship between the pair of nodes.In particular embodiments, an edge 206 may include or represent one ormore data objects or attributes corresponding to the relationshipbetween a pair of nodes. As an example and not by way of limitation, afirst user may indicate that a second user is a “friend” of the firstuser. In response to this indication, social-networking system 160 maytransmit a “friend request” to the second user. If the second userconfirms the “friend request,” social-networking system 160 may createan edge 206 connecting the first user's user node 202 to the seconduser's user node 202 in social graph 200 and store edge 206 associal-graph information in one or more of data stores 24. In theexample of FIG. 2, social graph 200 includes an edge 206 indicating afriend relation between user nodes 202 of user “A” and user “B” and anedge indicating a friend relation between user nodes 202 of user “C” anduser “B.” Although this disclosure describes or illustrates particularedges 206 with particular attributes connecting particular user nodes202, this disclosure contemplates any suitable edges 206 with anysuitable attributes connecting user nodes 202. As an example and not byway of limitation, an edge 206 may represent a friendship, familyrelationship, business or employment relationship, fan relationship,follower relationship, visitor relationship, subscriber relationship,superior/subordinate relationship, reciprocal relationship,non-reciprocal relationship, another suitable type of relationship, ortwo or more such relationships. Moreover, although this disclosuregenerally describes nodes as being connected, this disclosure alsodescribes users or concepts as being connected. Herein, references tousers or concepts being connected may, where appropriate, refer to thenodes corresponding to those users or concepts being connected in socialgraph 200 by one or more edges 206.

In particular embodiments, an edge 206 between a user node 202 and aconcept node 204 may represent a particular action or activity performedby a user associated with user node 202 toward a concept associated witha concept node 204. As an example and not by way of limitation, asillustrated in FIG. 2, a user may “like,” “attended,” “played,”“listened,” “cooked,” “worked at,” or “watched” a concept, each of whichmay correspond to an edge type or subtype. A concept-profile pagecorresponding to a concept node 204 may include, for example, aselectable “check in” icon (such as, for example, a clickable “check in”icon) or a selectable “add to favorites” icon. Similarly, after a userclicks these icons, social-networking system 160 may create a “favorite”edge or a “check in” edge in response to a user's action correspondingto a respective action. As another example and not by way of limitation,a user (user “C”) may listen to a particular song (“Imagine”) using aparticular application (SPOTIFY, which is an online music application).In this case, social-networking system 160 may create a “listened” edge206 and a “used” edge (as illustrated in FIG. 2) between user nodes 202corresponding to the user and concept nodes 204 corresponding to thesong and application to indicate that the user listened to the song andused the application. Moreover, social-networking system 160 may createa “played” edge 206 (as illustrated in FIG. 2) between concept nodes 204corresponding to the song and the application to indicate that theparticular song was played by the particular application. In this case,“played” edge 206 corresponds to an action performed by an externalapplication (SPOTIFY) on an external audio file (the song “Imagine”).Although this disclosure describes particular edges 206 with particularattributes connecting user nodes 202 and concept nodes 204, thisdisclosure contemplates any suitable edges 206 with any suitableattributes connecting user nodes 202 and concept nodes 204. Moreover,although this disclosure describes edges between a user node 202 and aconcept node 204 representing a single relationship, this disclosurecontemplates edges between a user node 202 and a concept node 204representing one or more relationships. As an example and not by way oflimitation, an edge 206 may represent both that a user likes and hasused at a particular concept. Alternatively, another edge 206 mayrepresent each type of relationship (or multiples of a singlerelationship) between a user node 202 and a concept node 204 (asillustrated in FIG. 2 between user node 202 for user “E” and conceptnode 204 for “SPOTIFY”).

In particular embodiments, social-networking system 160 may create anedge 206 between a user node 202 and a concept node 204 in social graph200. As an example and not by way of limitation, a user viewing aconcept-profile page (such as, for example, by using a web browser or aspecial-purpose application hosted by the user's client system 130) mayindicate that he or she likes the concept represented by the conceptnode 204 by clicking or selecting a “Like” icon, which may cause theuser's client system 130 to transmit to social-networking system 160 amessage indicating the user's liking of the concept associated with theconcept-profile page. In response to the message, social-networkingsystem 160 may create an edge 206 between user node 202 associated withthe user and concept node 204, as illustrated by “like” edge 206 betweenthe user and concept node 204. In particular embodiments,social-networking system 160 may store an edge 206 in one or more datastores. In particular embodiments, an edge 206 may be automaticallyformed by social-networking system 160 in response to a particular useraction. As an example and not by way of limitation, if a first useruploads a picture, watches a movie, or listens to a song, an edge 206may be formed between user node 202 corresponding to the first user andconcept nodes 204 corresponding to those concepts. Although thisdisclosure describes forming particular edges 206 in particular manners,this disclosure contemplates forming any suitable edges 206 in anysuitable manner.

Typeahead Processes

In particular embodiments, one or more client-side and/or back-end(server-side) processes may implement and utilize a “typeahead” featurethat may automatically attempt to match social-graph elements (e.g.,user nodes 202, concept nodes 204, or edges 206) to informationcurrently being entered by a user in an input form rendered inconjunction with a requested page (such as, for example, a user-profilepage, a concept-profile page, a search-results page, or another suitablepage of the online social network), which may be hosted by or accessiblein the social-networking system 160. In particular embodiments, as auser is entering text to make a declaration, the typeahead feature mayattempt to match the string of textual characters being entered in thedeclaration to strings of characters (e.g., names, descriptions)corresponding to user, concepts, or edges and their correspondingelements in the social graph 200. In particular embodiments, when amatch is found, the typeahead feature may automatically populate theform with a reference to the social-graph element (such as, for example,the node name/type, node ID, edge name/type, edge ID, or anothersuitable reference or identifier) of the existing social-graph element.

In particular embodiments, as a user types or otherwise enters text intoa form used to add content or make declarations in various sections ofthe user's profile page, home page, or other page, the typeahead processmay work in conjunction with one or more front-end (client-side) and/orback-end (server-side) typeahead processes (hereinafter referred tosimply as “typeahead process”) executing at (or within) thesocial-networking system 160 (e.g., within servers 162), tointeractively and virtually instantaneously (as appearing to the user)attempt to auto-populate the form with a term or terms corresponding tonames of existing social-graph elements, or terms associated withexisting social-graph elements, determined to be the most relevant orbest match to the characters of text entered by the user as the userenters the characters of text. Utilizing the social-graph information ina social-graph database or information extracted and indexed from thesocial-graph database, including information associated with nodes andedges, the typeahead processes, in conjunction with the information fromthe social-graph database, as well as potentially in conjunction withvarious others processes, applications, or databases located within orexecuting within social-networking system 160, may be able to predict auser's intended declaration with a high degree of precision. However,the social-networking system 160 can also provide users with the freedomto enter essentially any declaration they wish, enabling users toexpress themselves freely.

In particular embodiments, as a user enters text characters into a formbox or other field, the typeahead processes may attempt to identifyexisting social-graph elements (e.g., user nodes 202, concept nodes 204,or edges 206) that match the string of characters entered in the user'sdeclaration as the user is entering the characters. In particularembodiments, as the user enters characters into a form box, thetypeahead process may read the string of entered textual characters. Aseach keystroke is made, the front-end typeahead process may transmit theentered character string as a request (or call) to the back-endtypeahead process executing within social-networking system 160. Inparticular embodiments, the typeahead processes may communicate via AJAX(Asynchronous JavaScript and XML) or other suitable techniques, andparticularly, asynchronous techniques. In particular embodiments, therequest may be, or comprise, an XMLHTTPRequest (XHR) enabling quick anddynamic sending and fetching of results. In particular embodiments, thetypeahead process may also transmit before, after, or with the request asection identifier (section ID) that identifies the particular sectionof the particular page in which the user is making the declaration. Inparticular embodiments, a user ID parameter may also be sent, but thismay be unnecessary in some embodiments, as the user may already be“known” based on the user having logged into (or otherwise beenauthenticated by) the social-networking system 160.

In particular embodiments, the typeahead process may use one or morematching algorithms to attempt to identify matching social-graphelements. In particular embodiments, when a match or matches are found,the typeahead process may transmit a response (which may utilize AJAX orother suitable techniques) to the user's client system 130 that mayinclude, for example, the names (name strings) or descriptions of thematching social-graph elements as well as, potentially, other metadataassociated with the matching social-graph elements. As an example andnot by way of limitation, if a user entering the characters “pok” into aquery field, the typeahead process may display a drop-down menu thatdisplays names of matching existing profile pages and respective usernodes 202 or concept nodes 204, such as a profile page named or devotedto “poker” or “pokemon”, which the user can then click on or otherwiseselect thereby confirming the desire to declare the matched user orconcept name corresponding to the selected node. As another example andnot by way of limitation, upon clicking “poker,” the typeahead processmay auto-populate, or causes the web browser 132 to auto-populate, thequery field with the declaration “poker”. In particular embodiments, thetypeahead process may simply auto-populate the field with the name orother identifier of the top-ranked match rather than display a drop-downmenu. The user may then confirm the auto-populated declaration simply bykeying “enter” on his or her keyboard or by clicking on theauto-populated declaration.

More information on typeahead processes may be found in U.S. patentapplication Ser. No. 12/763,162, filed 19 Apr. 2010, and U.S. patentapplication Ser. No. 13/556,072, filed 23 Jul. 2012, which areincorporated by reference.

Search Queries and Search Clients

FIGS. 3A and 3B illustrate example user interfaces of an online socialnetwork. In particular embodiments, social-networking system 160 mayreceive from a querying/first user (corresponding to a first user node202) a search query. The user interface (UI) of a client system 130 mayinclude a search-query field 350 configured to receive the search queryfrom the querying user. In particular embodiments, the UI may beprovided by a native application associated with the online socialnetwork or by a webpage of the social-networking system accessed by abrowser client. The search query may be a text query, and may compriseone or more character strings, which may include one or more n-grams asdescribed below. A user may input a character string comprising one ormore characters into query field 350 to search for objects insocial-networking system 160 that substantially match the characterstring. The search query may also be a structured query comprisingreferences to particular nodes or edges from social graph 200. Thestructured queries may be based on the natural-language stringsgenerated by one or more grammars, as described in U.S. patentapplication Ser. No. 13/674,695, filed 12 Nov. 2012, and U.S. patentapplication Ser. No. 13/731,866, filed 31 Dec. 2012, each of which isincorporated by reference. As an example and not by way of limitation,the search query “Friends of Stephanie” may be a structured query, where“Friends” and “Stephanie” in the search query are referencescorresponding to particular social-graph elements. The reference to“Stephanie” corresponds to a particular user node 202 (wheresocial-networking system 160 has parsed the n-gram “my girlfriend” tocorrespond with a user node 202 for the user “Stephanie”), while thereference to “Friends” corresponds to friend-type edges 206 connectingthat user node 202 to other user nodes 202 (i.e., edges 206 connectingto “Stephanie's” first-degree friends). The search query may be receivedin any suitable manner, such as, for example, when the user inputs thesearch query into a query field 350 on a webpage of the online socialnetwork, as shown in FIG. 3A, or into a native application associatedwith the online social network, as shown in FIG. 3B.

In particular embodiments, social-networking system 160 may receive froma querying/first user (corresponding to a first user node 202) anunstructured text query. As an example and not by way of limitation, afirst user may want to search for other users who: (1) are first-degreefriends of the first user; and (2) are associated with StanfordUniversity (i.e., the user nodes 202 are connected by an edge 206 to theconcept node 204 corresponding to the school “Stanford”). The first usermay then enter a text query “friends stanford” into query field 350. Asthe querying user enters this text query into query field 350,social-networking system 160 may provide various suggested structuredqueries and/or typeahead suggestions for matching entries, asillustrated in a drop-down menu 300 or display area 360. As used herein,an unstructured text query refers to a simple text string inputted by auser. The text query may, of course, be structured with respect tostandard language/grammar rules (e.g. English language grammar).However, the text query will ordinarily be unstructured with respect tosocial-graph elements. In other words, a simple text query does notordinarily include embedded references to particular social-graphelements. Thus, as used herein, a structured query refers to a querythat contains references to particular social-graph elements, allowingthe search engine to search based on the identified elements.Furthermore, the text query may be unstructured with respect to formalquery syntax. In other words, a simple text query is not necessarily inthe format of a query command that is directly executable by a searchengine. For example, the text query “friends stanford” could be parsedto form the query command “intersect(school(Stanford University),friends(me))”, which could be executed as a query in a social-graphdatabase. As the querying user enters text query into query field 350,social-networking system 160 may provide typeahead suggestions formatching entries, e.g., a user “Freddie Rumsfeld,” for a user matchingthe typed prefix “fr” in addition to the suggested structured queries.Although this disclosure describes receiving particular queries in aparticular manner, this disclosure contemplates receiving any suitablequeries in any suitable manner. More information on search queries maybe found in U.S. patent application Ser. No. 13/556,060, filed 23 Jul.2012, and U.S. patent application Ser. No. 13/732,175, filed 31 Dec.2012, each of which is incorporated by reference.

In particular embodiments, social-networking system 160 may parse thesearch query received from the first user (i.e., the querying user) toidentify one or more n-grams. In general, an n-gram is a contiguoussequence of n items from a given sequence of text or speech. The itemsmay be characters, phonemes, syllables, letters, words, base pairs,prefixes, or other identifiable items from the sequence of text orspeech. The n-gram may comprise one or more characters of text (letters,numbers, punctuation, etc.) entered by the querying user. An n-gram ofsize one can be referred to as a “unigram,” of size two can be referredto as a “bigram” or “digram,” of size three can be referred to as a“trigram,” and so on. Each n-gram may include one or more parts from thesearch query received from the querying user. In particular embodiments,each n-gram may comprise a character string (e.g., one or morecharacters of text) entered by the first user. As an example and not byway of limitation, social-networking system 160 may parse the searchquery “all about recipes” to identify the following n-grams: all; about;recipes; all about; about recipes; all about recipes. In particularembodiments, each n-gram may comprise a contiguous sequence of n itemsfrom the search query. Although this disclosure describes parsingparticular queries in a particular manner, this disclosure contemplatesparsing any suitable queries in any suitable manner. In connection withelement detection and parsing search queries, particular embodiments mayutilize one or more systems, components, elements, functions, methods,operations, or steps disclosed in U.S. patent application Ser. No.13/556,072, filed 23 Jul. 2012, U.S. patent application Ser. No.13/732,101, filed 31 Dec. 2012, each of which is incorporated byreference.

Rewriting Search Queries

FIG. 4 illustrates an example search query pipeline. In particularembodiments, social-networking system 160 may receive a search query 404from a user 402. The social-networking system 160 may restrict thesearch to friends of the user 402, in which case users who are notfriends of the user 402 may not be included in the search results, evenif those users otherwise match the search query. Searching all users ofthe online social network may produce a large number of search results.For example, a search for a user with a common name, such as “MarkSmith,” is likely to return a large number of users. The search querypipeline shown in FIG. 4 may improve a search query 404 by generating arewritten query command 462 based on the search query 404 received fromthe querying user 402. The re-written query 462 may expand the search toidentify users who are related to the querying user or to search contextdata 412 in some way, e.g., by being friends-of-friends of the queryinguser. As an example and not by way of limitation, a query-rewritingcomponent 460 may generate the rewritten query 462 based on aclient-generated search query 432, back-end search context data 452,search context data 412, and/or related items 440 identified in aback-end search request 442. The back-end search context may be based oncorresponding items in the back-end search request 442. For example, thefriends of owner 454 may be based on the owner item 444, the friends oftagged 456 may be based on the tagged item 445, and the commenter 458may be based on the commenter item 448. The client-generated searchquery 432 may be a structured query generated by a search client 406based on the user-provided search query 404. The search client 406 maybe part of a user interface (UI) on web browser 132 of client system130, or may be part of a UI on a native application of client system130. As an example and not by way of limitation, a tagging UI of webbrowser 132 may be configured to display a digital image 409 and allowtagging one or more users in the digital image 409, e.g., by associatingeach user's ID with portions of the image in which the user appears. Asfurther described below, suggested tags may be retrieved through theautomatically-generated client search query 432 generated by the UI.

In particular embodiments, as introduced above, the client-generatedsearch query 432 may include or be based upon search context data 412associated with the particular search client 406 generating the searchquery 432. The search client 406 can generate the search context data412 by extracting page signals 410 from the content or page 408associated with the search client 406 in the web browser 132. Thecontent or page 408 may include one or more types of content, such as apost, a digital image, or other digital media object. The search client406 can be displayed on or in association with the content or page 408.The search client 406 can be displayed when, for example, the user 402has selected a command to indicate that the user likes or wishes toshare the content or page 408, or an image, post, page, or other contentitem displayed on or in association with the content or page 408. Thepage signals 410 may be data items included in the content or page 408in a structured format. The content or page 408 can be parsed orprocessed to extract the data items for each type of signal 414, ifpresent. Upon being extracted from the content or page 408, the pagesignals 410 may be stored in the search context data 412 as contextsignals 414. The context signals 414 may include social context data415, such as an owner 416 of the content or page 408, commenters 418,tags 420, comments 422, likes 424, shares 426, and so on. As an exampleand not by way of limitation, in a comment-tag context, e.g., when a tagidentifying a user is added to a comment, the search context data 412may include a tag signal 420 that identifies a user being tagged in thecontent or page 408. The search context data 412 may also includeinformation that identifies the particular search client 406 associatedwith the tagging UI on the web browser 132. The search context data 412can also configure retrieval of a particular type of social graphelements, with the retrieval to be performed by the search back-end 450in response to query commands corresponding to the client search query432. In particular embodiments, the client search query 432 may includedata identifying a particular social-graph element associated with thesearch query 432, such as, for example, an unique identifier for adigital image 409 being tagged, an identifier of a user being tagged, oranother suitable identifier of a social-graph element.

In particular embodiments, the client search query 432 and a searchcontext object identifier 433 may be sent by client system 130 tosocial-networking system 160 through network 110 in a client searchrequest 431. The context object identifier (ID) 433 may be a referenceto the search context data 412, so that the search context data 412 neednot be sent through the network 110. The client search query 432 andcontext data 412 may be processed by a search front-end 434 ofsocial-networking system 160. As an example and not by way oflimitation, the search front-end 434 may be implemented using ascripting programming language, such as, for example, PHP. In particularembodiments, the search front-end 434 may extract from the client searchquery 432 an object identifier 436 identifying the particularsocial-graph element associated with the client search query 432, andperform a search of one or more search indices of data stores 164.Furthermore, the search performed by the search front-end 434 mayretrieve references 440 to other social-graph elements associated withthe particular social-graph element identified by the object ID 436based at least in part on the context data 412. As an example and not byway of limitation, the social-graph elements associated with a digitalimage 409 that are retrieved from the data store 164 based on taggingcontext data 412 may include identities of the user/owner 416 thatposted the digital image 409, users tagged in the digital image 409, orusers that have commented on the digital image 409. As another example,the social-graph elements associated with a post that are retrievedbased on comment context data 422 may include the user/owner 416 thatinitiated the post, users/commenters 418 that commented on the post, orusers 424 that “liked” the post.

One or more expanded query commands 443 generated from a structuredclient search query 432 may be used in a search for objects in one ormore data stores 164 of the social-networking system 160. In particularembodiments, the search front-end 434 may generate the one or moreexpanded query commands 443 based at least in part on the search query432 generated by the search client 406 of client system 130. Theexpanded query commands 443 may be provided for a search using searchindices for one or more data stores 164 of social-networking system 160.The search back-end 450 may receive a back-end search request 442 thatincludes the expanded query commands 443 and references to one or moresocial-graph elements associated with the expanded query commands 443from the search front-end 434. In particular embodiments, the searchfront-end 434 may modify one or more of the client search query commands432 to incorporate the social-graph elements associated with the clientsearch query 432 and context data 412 to form the back-end searchrequest 442. The back-end search request 442 can include one or more ofthe context signals 414 from the search context data 412, such as anowner signal 444, a tagged signal 446, and a commenter signal 448. Theback-end search request 442 can also include a context object ID 433that refers to the search context data 412, so that signal values neednot be included in the back-end search request 442.

The expanded query commands 443 may be modified by the query rewritingcomponent 460 to form a rewritten query command 462, which may includeone or more query constraints. In particular embodiments, one or more ofthe query constraints may be social-graph elements identified based onthe search context data 412. Query constraints may be identified bysocial-networking system 160 based on a parsing of the client searchquery 404 or references to particular social-graph elements identifiedbased on the search context data 412 from the particular search client406. Each query constraint may be a request for a particularobject-type. In particular embodiments, the rewritten query command 462may comprise query constraints in symbolic expression or s-expressionform. As an example, social-networking system 160 may parse the searchquery 404 “Photos I like” to a query command 462 (photos_liked_by:<me>).The query command (photos_liked_by: <me>) denotes a query for photosliked by a user (i.e., <me>, which corresponds to the querying user402), with a single result-type of photo. The query constraint mayinclude, for example, social-graph constraints (e.g., requests forparticular nodes or node-types, or requests for nodes connected toparticular edges or edge-types), object constraints (e.g., requests forparticular objects or object-types), location constraints (e.g.,requests for objects or social-graph entities associated with particulargeographic locations), other suitable constraints, or any combinationthereof. In particular embodiments, the parsing of the search query 404may be based on the grammar used to generate the search query 404. Inother words, the rewritten query command 462 and its query constraintsmay correspond to a particular grammar.

In particular embodiments, a rewritten query command 462 may comprise aprefix and an object. The object may correspond to a particular node inthe social graph 200, while the prefix may correspond to a particularedge 206 or edge-type (indicating a particular type of relationship)connecting to the particular node in the social graph 200. As an exampleand not by way of limitation, the query command (pages_liked_by:<user>)comprises a prefix pages_liked_by, and an object <user>. In particularembodiments, social-networking system 160 may execute a query command462 by traversing the social graph 200 from the particular node alongthe particular connecting edges 206 (or edge-types) to nodescorresponding to objects specified by the query command to identify oneor more initial search results (not shown) that can be passed to aranking component 466 or used as search results 472 themselves (e.g.,without being processed by the ranking component 466). As an example andnot by way of limitation, the query command (pages_liked_by:<user>) maybe executed by social-networking system 160 by traversing the socialgraph 200 from a user node 202 corresponding to <user> along like-typeedges 206 to concept nodes 204 corresponding to pages liked by <user>.In one aspect, modifying the query may be based at least in part on oneor more identified n-grams in the query, and the modified (e.g.,rewritten) query may reference one or more second nodes referenced inthe identified n-grams. Although this disclosure describes generating ormodifying particular query commands in a particular manner, thisdisclosure contemplates generating or modifying any suitable querycommands in any suitable manner.

In particular embodiments, a parsing algorithm used to generate querycommands may comprise one or more parsing-configuration parameters. Theparsing-configuration parameters may specify how to generate a rewrittenquery command 462 for a particular type of query 404 received from auser 402. The parsing-configuration parameters may specify, for example,instructions for generating a rewritten query command 462 having aspecified number of query constraints for a specified number of objectsof a specified object-type to be retrieved from a specified number ofdata stores 164. In particular embodiments, social-networking system 160may access one or more data stores 164 in response to a search query 404received from a user 402. Each data store 164 may store one or moreobjects associated with the online social network. In particularembodiments, social-networking system 160 may search each accessed datastore 164 to identify one or more objects associated with the data store164 that substantially match the search query 404. Social-networkingsystem 160 may identify matching objects in any suitable manner, suchas, for example, by using one or more string matching algorithms tomatch a portion of the search query 404 with a string of charactersassociated with each of one or more of the objects. Rewriting may usethe friends_of: <owner> and friends_of: <tagged> constraints to improverecall (i.e., a measure of whether the search finds the informationbeing searched for). As an example and not by way of limitation, inresponse to a search query input 404 “kais” and context data 412associated with tagging a digital image 409, the search back-end 450 ofsocial-networking system 160 may generate the following rewritten querycommand 462:

(AND (name: “kais”)

-   -   (OR friends_of: <owner>)    -   (OR friends_of: <tagged>)).        This query command 462 contains a first query constraint (OR        friends_of: <owner>), which instructs social-networking system        160 to access data store 164 to search for users that are        friends of the user that owns the digital image 409 and that        match the character string “kais,” and to retrieve the top fifty        results. The second query constraint, (OR friends_of: <tagged>),        instructs social-networking system 160 to access data store 164        to search for users tagged in the digital image 409 that match        the character string “kais.” Social-networking system 160 may        access the index servers of each data store 164 to return        results that match the rewritten query command 462. Although        this disclosure describes identifying particular objects in a        particular manner, this disclosure contemplates identifying any        suitable objects in any suitable manner. More information on        accessing and searching data stores 164 may be found in U.S.        patent application Ser. No. 13/560,212, filed 27 Jul. 2012, and        U.S. patent application Ser. No. 13/870,113, filed 25 Apr. 2013,        each of which is incorporated by reference.

Improving Search Results Based on Search Client Context

In particular embodiments, social-networking system 160 may generateimproved search results 472 based on the search context data 412 of thesearch client(s) 406. In one aspect, as described above, the searchclient 406 executes in a web browser 132 or other application andreceives a search query 404 from a user 402. The search client 406generates a client search request 431 based on the search query 404, andsends the client search request 431 to a search front-end 434. Thesearch front-end 434 generates a back-end search request 442 based onthe client search request 431 and items related to objects 436 specifiedin the search request 431. The back-end search request 442 may alsoinclude the context object ID 433 that references the search contextdata 412, and/or specific signals from the search context data 412. Thesearch front-end 434 may send one or more object IDs 436 to the datastore 164 and receive one or more item IDs 440 identifying other objectsthat are related to the object IDs 436. The data store 164 may be, forexample, an in-memory data structure such as memcache, a hybridin-memory and disk storage system such as TAO (“The Associations andObjects”), or the like. The search front-end 434 may send the expandedquery 443 to a search back-end 450 via network 110. The search back-end450 may use a query rewriting component 460 to generate a rewrittensearch query 462 based on the expanded query 443. The re-written query462 may expand the search to identify users who are related to thequerying user 402 or the search context data 412 in some way, e.g., bybeing friends of friends of the querying user 402, being authors ofcomments on the page 408 (included in the commenters 418), and so on.The search back-end 450 may then send the rewritten search query 462 toa searching component 464, e.g., a search engine that searches the datastores 164 and generates initial search results (not shown).

A ranking component 466 may then rank or re-rank the initial searchresults produced by the expanded search query 462 using the searchcontext data 412. The ranking component 466 may use the signals andobjects included in the back-end search request 442, including thecontext signals 414 from the search context data 412 generated by thesearch client 406. As described above, the signals 414 in the searchcontext data 412 can include a social context 415, such as an owner 416,commenters 418, tags 420, comments 422, likes 424, and shares 426. Thesignals can also include functions 428, web suggestions 429, andgeo-location information 430. The ranking component 466 scores theobjects in the set of initial search results by computing features onthe objects. The features correspond to the context signals 414 and maybe binary features, i.e., binary factors, that are assigned a value of 1when present and 0 when absent. Other types of features may havecontinuous values. A model may be computed offline to establish a weightfor particular ranges of values. If a binary feature is present, thenthe weight corresponding to that feature is added to a sum of weightsfor that feature. The sum for each object corresponds to a score thatdetermines the object's rank, e.g., position, in the search results 472.The ranking component 466 therefore may boost more relevant searchresults, to be closer to the top of the list of search results 472. Thetop-scoring objects (as limited by the search client 406 on the page408) can then be sent back to the web browser 132 and presented to theuser 402.

As described above, a search client 406 may be part of a user interfaceon web browser 132 or a native application of client system 130. Thesearch client 406 may be associated with a particular type of page ofsocial-network system 160. Search functionality may be incorporated intocontent 408, e.g., pages to be viewed by the user 402, with each pagehaving a customized search client 406 for performing a type of searchrelevant for that type of page or content 408. For example, a typeaheadsearch function 428 may be used for comments and photos when taggingpeople. Similarly, a graph search function 428 may be used for a homepage or landing page associated with the online social network. Thesearch results 472 can be ranked differently by the ranking component466 depending on how the search client 406 is being used, e.g.,depending on the search context data 412. For example, the top fivesearch results in a photo-tag search context (in which a photo is taggedwith a user or page ID identified by a tag signal 420) are likely to bedifferent from the top five results in a comment-tag search context (inwhich a comment is tagged with a user or page ID identified by a tagsignal 420). The suggested search results presented to a user in each ofthese scenarios can be customized based on context signals 410 extractedfrom the content or page 408. These signals 410 from the content or page408 may be stored in the context data 412 of the search client 406 assignals 414. The signals 414 can be used by the ranking component 466 toimprove the ranking of search results 472. For example, better searchresults 472 or suggestions can be presented to the user by taking intoaccount information associated with the content or page 408 on which thesearch client 406 user interface is presented. Although this disclosuredescribes improving search results 472 based on search context data 412associated with the search client 406 in a particular manner, thisdisclosure contemplates improving search results 472 based on contentdata 408 associated with the search client 406 in any suitable manner.

In particular embodiments, social-networking system 160 may receive fromthe first user 402 a search query 404 inputted by (or otherwise receivedfrom) the first user 402 at a search client 406. The search client 406can be, for example, a user interface that is presented on a page orother content 408 and can receive search query strings 404 from thefirst user 402. In particular embodiments, the search client 406 may beassociated with context data 412 from the page or content 408 associatedwith the search client 406. The context data 412 may include a socialcontext 415 of the page 408 associated with the search client 406. Thesocial context 415 of the search client 406 ordinarily refers to edgesand nodes connected to the node that corresponds to the content or page408 associated with the search client 406. For example, the socialcontext 415 of the post can include one or more of the following signals414: user ID of the original poster, shown as owner 416, priorcommenters on the post as commenters 418, people tagged in the post astags 420, people tagged in the comments as comments 422, people who haveliked the post as likes 424, people with whom the post has been sharedas shares 426, and other signals based on the content or page 408. Forexample, the social context 415 can include one or more of those signalswhen the user 402 is commenting on a post on the page 408, In oneexample, when adding a new comment and tagging a person via typeaheadsuggestions, the people within the social context 415 of the searchclient 406 (e.g., the users connected by edges to the post, content, orpage 408), can be ranked higher in a typeahead list, such as thedropdown 300 of FIG. 3A, than people not in the social context 415 ofthe search client 406 (e.g., users not connected to the post, content,or page 408). In particular embodiments, the context data 412 mayidentify one or more nodes of the plurality of nodes associated with thepage 408. As an example and not by way of limitation, the context data412 identifying nodes associated with the page 408 may include comments422 on a photo on the page 408, where the photo corresponds to a firstnode, and each comment 422 may correspond to a second node that isconnected to the first node by an edge 206. In particular embodiments,the context data 412 may identify a function 428 associated with thesearch client. As an example and not by way of limitation, the contextdata may identify a function 428 of the search client for performing atype of search relevant for that page. As described above, the function428 can be a typeahead search function, a graph search function, orother type of search function. In particular embodiments, the contextdata 412 may identify web suggestions 429 that can be received from asearch engine. As an example and not by way of limitation, the contextdata 412 may identify geographic location information 430 about thefirst user 402, such as current location of the first user, speed ofmovement of the first user, direction of movement of the first user,other suitable location information, or any combination thereof. Inparticular embodiments, the context data may identify one or more secondnodes connected by an edge to a particular node corresponding to thepage 408 of the search client 406. As an example and not by way oflimitation, if the page 408 of the search client is a page for a User“C”, then the context data may identify a second node 204 correspondingto the School “Stanford” connected by an edge 206 to the user node 202for User “C”. Although this disclosure describes receiving particularqueries 404 and context data 412 in a particular manner, this disclosurecontemplates receiving any suitable queries and context data in anysuitable manner.

In particular embodiments, social-networking system 160 may generate oneor more search results 472 corresponding to the query 404. Searchresults 472 can be improved based on the search context data 412 of thesearch client 406. The search can be performed by accessing a socialgraph 200 comprising a plurality of nodes and a plurality of edges 206.The nodes may include a first node 202 corresponding to the first user402 of the social network, and a plurality of second nodes that eachcorrespond to a concept or second user associated with the socialnetwork. The social context 415 of the search client can identify one ormore second nodes from the plurality of second nodes associated with thepage. One or more search results 472 for the query 404 can be generatedby the searching component 464. Each of the search results 472 maycorrespond to a node of the plurality of nodes. Although this disclosuredescribes generating particular search results 472 in a particularmanner, this disclosure contemplates generating any suitable searchresults in any suitable manner.

In particular embodiments, social-networking system 160 may score thesearch results 472 based at least in part on the signals 414 in thecontext data 412 associated with the search client 406, and use thescores to rank the search results 472 so that individual results bettermatching the query 404 appear closer to the top of the list of results.That is, search results that are more relevant to the search contextdata 412 associated with the search client 406 may be scoredbetter/higher than search results that are less relevant to the searchcontext data 412. As an example and not by way of limitation,search-client dependent signals 414 for tagging photos or images 409 mayinclude information referencing friends of the owner of the photo,interested users (e.g. commenters 418 who comment on the photo), andtagged users 420. When scoring search results matching a query inputtedinto a search client for tagging such a photo, social-networking system160 may score search results corresponding to friends of the owner(i.e., users corresponding to user nodes 202 connected by an edge to theuser node 202 of the querying user) of the photo better than searchresults corresponding to friends-of-friends of the owner. As anotherexample and not by way of limitation, when searching for a user of theonline social network by name using a search client on a particularpage, social-networking system 160 may score a subset of search results472 corresponding to authors of comments posted on that page higher thananother subset of search results 472 corresponding to users who are notauthors of comments on that page. In one aspect, search resultscorresponding to users who are connected to the querying user 402, e.g.,through a friend relationship or a signal 414 in search context data412, may be ranked better than results corresponding to users who arenot connected to the querying user 402 in either of those ways. Inparticular embodiments, social-networking system 160 may rank the searchresults 472 based on the scoring. Although this disclosure describesscoring particular search results in a particular manner, thisdisclosure contemplates scoring any suitable search results in anysuitable manner.

In particular embodiments, social-networking system 160 may customizesearch results 472 based on particular limitations/requirementsassociated with the search client 406. Searches performed by differentsearch clients may have requirements that are specific to each searchclient. As an example and not by way of limitation, searching forsuggested users when tagging users in photos may require retrieval of aparticular number search results (e.g., displaying the top-3 or top-5results, instead of the usual top-8), or retrieval of only certain typesof social-graph entities (e.g., users/friends, pages, etc.). As anexample, the number of suggestions or results for a search query 404 maybe different based on a type of media content 408 associated with thesearch client 406. If the search client is displayed with or near aphoto or image 409, then the top three of the search results 472 may bedisplayed. If the search client is associated with text content, thenthe top eight results may be displayed. The top ten results may bedisplayed for search clients associated with video content. In oneaspect, social-networking system 160 may filter search results based onthe search client 406. As another example, when a user is tagging aphoto, a displayed list of suggestions from search results 472 shouldinclude only users. On a splash page or new page, any type of entity maybe suggested in a list of suggestions, including pages, locations, andusers. Although this disclosure describes customizing search results ina particular manner, this disclosure contemplates customizing searchresults in any suitable manner.

FIG. 5 illustrates an example UI with search results. In particular,FIG. 5 illustrates a page for a picture posted by the user “Matthew” ofthe online social network. This picture may correspond to a particularconcept node 204 of social graph 200, which may be connected by an edge206 to the user node 202 of the user “Matthew.” The page may include,for example, a selectable “like” icon 522, a selectable “comment” icon534, a history of comments and “likes” from various users in field 536,an indication of the application corresponding to the concept node infield 538, other suitable components, or any combination thereof,information about which may be included in the context data associatedwith the search client. In particular embodiments, in response to asearch query received from a querying user, social-networking system 160may generate one or more search results 520, where the search resultscorrespond to the search query. Each search result may correspond to anode of the social graph 200. Social-networking system 160 may identifyobjects (e.g., users, photos, profile pages (or content of profilepages), etc.) that satisfy or otherwise match the search query. A searchresult 520 corresponding to each identified object may then begenerated. Although this disclosure describes generating search resultsin a particular manner, this disclosure contemplates generating searchresults in any suitable manner. More information on generating searchresults may be found in U.S. patent application Ser. No. 13/731,939,filed 31 Dec. 2012, which is incorporated by reference.

In particular embodiments, social-networking system 160 may send one ormore of the search results to the querying user for display based on thescores of the search results. In particular embodiments, the searchresults are displayed in association with the search client. As anexample and not by way of limitation, social-networking system 160 maydisplay search results in a drop-down 300 below a search field 350 asshown in FIG. 5. In particular embodiments, social-networking system 160may send a threshold number of search results for display to the firstuser 402. In the example illustrated in FIG. 5, four search resultsmatching the search string “rho” are displayed in drop-down 300, withthe threshold number for the search being the top four search results.The search context data 412 may identify the threshold number of searchresults for display. As an example and not by way of limitation, theclient search request 431 may specify that the threshold number is ten.The threshold value ten may correspond to the ten highest-ranking searchresults, or to search results having a score greater than ten, ormeeting a threshold value of ten according to another appropriatemetric. In response, the search back-end 450 may send the search resultsthat meet the threshold back to the search client for display. As anexample and not by way of limitation, social-networking system 160 maysend up to the threshold number of the highest scoring search resultsfor display to the first user 402 in response to the search request,instead of sending search results having scores that meet or exceed thethreshold score. Although this disclosure describes sending particularsearch results in a particular manner, this disclosure contemplatessending any suitable search results in any suitable manner.

As described below, search results 520 may be sent to the first user anddisplayed in a drop-down menu 300 (via, for example, a client-sidetypeahead process), where the first user can then select an appropriatesearch result 520. In particular embodiments, the search results 520 maybe sent to the user, for example, in the form of a list of links on thesearch-results page, each link being associated with a different pagethat contains some of the identified resources or content. In particularembodiments, each link in search results 520 may be in the form of aUniform Resource Locator (URL) that specifies where the correspondingpage is located and the mechanism for retrieving it. Social-networkingsystem 160 may then send the search-results page to the web browser 132on the user's client system 130. The user may then click on the URLlinks or otherwise select the content from the search-results page toaccess the content from social-networking system 160 or from an externalsystem (such as, for example, third-party system 170), as appropriate.In particular embodiments, each search result 520 may include a link toa profile page and a description or summary of the profile page (or thenode corresponding to that page). In particular embodiments, the searchresults may be presented and sent to the querying user as asearch-results page. When generating the search results,social-networking system 160 may generate one or more snippets for eachsearch result, where the snippets are contextual information about thetarget of the search result (i.e., contextual information about thesocial-graph entity, profile page, or other content corresponding to theparticular search result). In particular embodiments, social-networkingsystem 160 may only send search results having a score or rank over aparticular threshold score or rank. As an example and not by way oflimitation, social-networking system 160 may only send the top tensearch results 520 to the querying user in response to a particularsearch query.

In particular embodiments, a user interface (UI) with search results 520may be configured to receive input from a user selecting a region (e.g.,a selected region) within a digital image 540 according to the input. Asan example and not by way of limitation, the user clicks on a point ofdigital image 540 thereby placing a border 550 around the selectedregion. In particular embodiments, the shape of the selected region maybe a rectangle, circle, ellipse, polygon, or any suitable shape. Inparticular embodiments, a line, highlight, or some other indicia may besuperimposed on the digital image 540 to indicate the selected region.In particular embodiments, a “tag” in the form of text may be associatedwith the selected region of digital image 540. As an example and not byway of limitation, the text may include a hyperlink, an e-mail addressor user identification (ID) of a friend in the social-network system160, or any suitable information.

In particular embodiments, the UI may be configured to display a list oflikely tags to associate with the selected region defined by border 550.Furthermore, search results 520 corresponding to tags may be displayedin drop-down menu 300 in response to clicking on the selected region ofdigital image 740. As an example and not by way of limitation, the UImay include a search-query field 350 and drop-down menu 300auto-populated with search results 520 relevant to the querying user. Asdescribed below, search results 520 in down-down menu 300 may bedisplayed in a ranked order based at least in part on a score. As anunstructured search query (e.g. text) is entered in the search-queryfield 350, the displayed search results 520 may be modified to includesearch results 520 that at least partially match n-grams of theunstructured search query identified in some manner (via, for example, aclient-side typeahead process). In particular embodiments, clicking anyof the displayed search results 520 may associate the selected region toone or more social-graph elements referenced by the selected searchresult 520. Although this disclosure describes sending particular searchresults in a particular manner, this disclosure contemplates sending anysuitable search results in any suitable manner.

In particular embodiments, social-networking system 160 may score thesocial-graph elements referenced by search results 520. The social-graphelements may be scored based on one or more factors, such as, forexample, social-graph information, social-graph affinity, searchhistory, privacy settings, other suitable factors, or any combinationthereof. In particular embodiments, social-networking system 160 mayscore the objects based on a social-graph affinity associated with thequerying user (or the user node 202 of the querying user).Social-networking system 160 may determine the social-graph affinity(which may be referred to herein as “affinity”) of various social-graphentities for each other. Affinity may represent the strength of arelationship or level of interest between particular objects associatedwith the online social network, such as users, concepts, content,actions, advertisements, other objects associated with the online socialnetwork, or any suitable combination thereof. In particular embodiments,social-networking system 160 may measure or quantify social-graphaffinity using an affinity coefficient (which may be referred to hereinas “coefficient”). The coefficient may represent or quantify thestrength of a relationship between particular objects associated withthe online social network. The coefficient may also represent aprobability or function that measures a predicted probability that auser will perform a particular action based on the user's interest inthe action. Although this disclosure describes scoring objects in aparticular manner, this disclosure contemplates scoring objects in anysuitable manner.

In particular embodiments, when searching data stores 164 to identifymatching social-graph elements, social-networking system 160 may onlyidentify and score up to a threshold number of matching nodes or edgesin a particular data store 164. This threshold number of matchingobjects may then be scored and ranked by the social-networking system160. The threshold number may be chosen to enhance search quality or tooptimize the processing of search results. As an example and not by wayof limitation, social-networking system 160 may only identify the top Nmatching social-graph elements (i.e., the number to score) in a user'sdata store 164 in response to a query command requesting users. The topN social-graph elements may be determined by a static ranking (e.g.,ranking based on the current social-graph affinity of the user withrespect to the querying user) of the social-graph elements referenced ina search index corresponding to the users data store 164. In particularembodiments, the top N identified object may be re-ranked based on thesearch query itself. As an example and not by way of limitation, if thenumber to score is 500, the top 500 objects may be identified. These 500objects may then be ranked based on one or more factors (e.g., match tothe search query or other query constraints, social-graph affinity,search history, etc.), and the top M results may then be sent to thesearch front-end to be checked for privacy control before beinggenerated as search results. In particular embodiments, the top resultsafter one or more rounds of rankings may be sent to an aggregator for afinal round of ranking, where identified objects may be reordered,redundant results may be dropped, or any other type ofresults-processing may occur before presentation to the querying user.Although this disclosure describes identifying particular numbers ofobjects, this disclosure contemplates identifying any suitable numbersof objects. Furthermore, although this disclosure describes rankingobjects in a particular manner, this disclosure contemplates rankingobjects in any suitable manner.

FIG. 6 illustrates an example method 600 for optimizing search resultsbased on contextual information. The contextual information can be, forexample, information extracted from a page on which a user provided asearch query as input to a search client. In one aspect, optimizationbased on contextual information, such as signals on the page, may bedone by rewriting search queries on the back-end so that more relevantresults may be retrieved. The method may begin at step 610, wheresocial-networking system 160 may access a social graph 200 comprising aplurality of nodes and a plurality of edges 206 connecting the nodes.Each of the edges 206 between two of the nodes may represent a singledegree of separation between them. The nodes may comprise a first node(e.g., a user node 202) corresponding to a first user associated with anonline social network and a plurality of second nodes, each of whichcorresponds to a concept or a second user associated with the onlinesocial network.

At step 620, social-networking system 160 may receive from the firstuser a query inputted by the first user at a search client. The searchclient may be associated with context data 412 from the page associatedwith the search client. The context data 412 may include context signals414 and may identify one or more second nodes of the plurality of secondnodes associated with the page. As an example, a search front-end (e.g.,a UI of a native application) may send the context signals to the searchback-end (e.g., the social-networking system), where the query can berewritten, and objects that match the query and context data can beretrieved from one or more data stores 164. For example, search-clientdependent signals for tagging photos may include information referencingfriends of the owner of the photo, interested users (e.g. users whocomment on the photo), and tagged users. At step 630, social-networkingsystem 160 may generate one or more search results corresponding to thequery. Each of the search results corresponds to a node of the pluralityof the plurality of nodes. For example, the search back-end may processthe search query (e.g., a search for users to tag in a photo) with thecontext-based signals from the search front-end, and re-write the searchquery to form a re-written search expression that incorporates thecontext-based signals. The re-written search expression may include theuser-provided search terms and the context-based signals. These signalsmay include search-client dependent signals, current location, speed, ordirection of movement of the user, or web suggestions from other searchengines. Rewriting the search expression may refine the search anddecrease the number of objects retrieved from each data store 164, thusimproving search efficiency. At step 640, social-networking system 160may score the search results based at least in part on the context dataassociated with the search client. For example, the retrieved objectsmay be ranked based on a scoring algorithm that factors in thecontext-based signals. The context-based signals may be processed asbinary factors, such that if a particular context-based signal ispresent, the score is increased by a weighting of the particularcontext-based signal. At step 650, social-networking system 160 may sendone or more of the search results to the first user for display based onthe scores of the search results. As an example, the top-scoring objects(as limited by the search client on that page) can then be sent back tothe page and presented to the user. Particular embodiments may repeatone or more steps of the method of FIG. 6, where appropriate. Althoughthis disclosure describes and illustrates particular steps of the methodof FIG. 6 as occurring in a particular order, this disclosurecontemplates any suitable steps of the method of FIG. 6 occurring in anysuitable order. Moreover, although this disclosure describes andillustrates an example method for optimizing search results basedcontextual information including the particular steps of the method ofFIG. 6, this disclosure contemplates any suitable method for optimizingsearch results based contextual information including any suitablesteps, which may include all, some, or none of the steps of the methodof FIG. 6, where appropriate. Furthermore, although this disclosuredescribes and illustrates particular components, devices, or systemscarrying out particular steps of the method of FIG. 6, this disclosurecontemplates any suitable combination of any suitable components,devices, or systems carrying out any suitable steps of the method ofFIG. 6.

Social Graph Affinity and Coefficient

In particular embodiments, social-networking system 160 may determinethe social-graph affinity (which may be referred to herein as“affinity”) of various social-graph entities for each other. Affinitymay represent the strength of a relationship or level of interestbetween particular objects associated with the online social network,such as users, concepts, content, actions, advertisements, other objectsassociated with the online social network, or any suitable combinationthereof. Affinity may also be determined with respect to objectsassociated with third-party systems 170 or other suitable systems. Anoverall affinity for a social-graph entity for each user, subjectmatter, or type of content may be established. The overall affinity maychange based on continued monitoring of the actions or relationshipsassociated with the social-graph entity. Although this disclosuredescribes determining particular affinities in a particular manner, thisdisclosure contemplates determining any suitable affinities in anysuitable manner.

In particular embodiments, social-networking system 160 may measure orquantify social-graph affinity using an affinity coefficient (which maybe referred to herein as “coefficient”). The coefficient may representor quantify the strength of a relationship between particular objectsassociated with the online social network. The coefficient may alsorepresent a probability or function that measures a predictedprobability that a user will perform a particular action based on theuser's interest in the action. In this way, a user's future actions maybe predicted based on the user's prior actions, where the coefficientmay be calculated at least in part on a history of the user's actions.Coefficients may be used to predict any number of actions, which may bewithin or outside of the online social network. As an example and not byway of limitation, these actions may include various types ofcommunications, such as sending messages, posting content, or commentingon content; various types of an observation actions, such as accessingor viewing profile pages, media, or other suitable content; varioustypes of coincidence information about two or more social-graphentities, such as being in the same group, tagged in the samephotograph, checked-in at the same location, or attending the sameevent; or other suitable actions. Although this disclosure describesmeasuring affinity in a particular manner, this disclosure contemplatesmeasuring affinity in any suitable manner.

In particular embodiments, social-networking system 160 may use avariety of factors to calculate a coefficient. These factors mayinclude, for example, user actions, types of relationships betweenobjects, location information, other suitable factors, or anycombination thereof. In particular embodiments, different factors may beweighted differently when calculating the coefficient. The weights foreach factor may be static or the weights may change according to, forexample, the user, the type of relationship, the type of action, theuser's location, and so forth. Ratings for the factors may be combinedaccording to their weights to determine an overall coefficient for theuser. As an example and not by way of limitation, particular useractions may be assigned both a rating and a weight while a relationshipassociated with the particular user action is assigned a rating and acorrelating weight (e.g., so the weights total 100%). To calculate thecoefficient of a user towards a particular object, the rating assignedto the user's actions may comprise, for example, 60% of the overallcoefficient, while the relationship between the user and the object maycomprise 40% of the overall coefficient. In particular embodiments, thesocial-networking system 160 may consider a variety of variables whendetermining weights for various factors used to calculate a coefficient,such as, for example, the time since information was accessed, decayfactors, frequency of access, relationship to information orrelationship to the object about which information was accessed,relationship to social-graph entities connected to the object, short- orlong-term averages of user actions, user feedback, other suitablevariables, or any combination thereof. As an example and not by way oflimitation, a coefficient may include a decay factor that causes thestrength of the signal provided by particular actions to decay withtime, such that more recent actions are more relevant when calculatingthe coefficient. The ratings and weights may be continuously updatedbased on continued tracking of the actions upon which the coefficient isbased. Any type of process or algorithm may be employed for assigning,combining, averaging, and so forth the ratings for each factor and theweights assigned to the factors. In particular embodiments,social-networking system 160 may determine coefficients usingmachine-learning algorithms trained on historical actions and past userresponses, or data farmed from users by exposing them to various optionsand measuring responses. Although this disclosure describes calculatingcoefficients in a particular manner, this disclosure contemplatescalculating coefficients in any suitable manner.

In particular embodiments, social-networking system 160 may calculate acoefficient based on a user's actions. Social-networking system 160 maymonitor such actions on the online social network, on a third-partysystem 170, on other suitable systems, or any combination thereof. Anysuitable type of user actions may be tracked or monitored. Typical useractions include viewing profile pages, creating or posting content,interacting with content, tagging or being tagged in images, joininggroups, listing and confirming attendance at events, checking-in atlocations, liking particular pages, creating pages, and performing othertasks that facilitate social action. In particular embodiments,social-networking system 160 may calculate a coefficient based on theuser's actions with particular types of content. The content may beassociated with the online social network, a third-party system 170, oranother suitable system. The content may include users, profile pages,posts, news stories, headlines, instant messages, chat roomconversations, emails, advertisements, pictures, video, music, othersuitable objects, or any combination thereof. Social-networking system160 may analyze a user's actions to determine whether one or more of theactions indicate an affinity for subject matter, content, other users,and so forth. As an example and not by way of limitation, if a user maymake frequently posts content related to “coffee” or variants thereof,social-networking system 160 may determine the user has a highcoefficient with respect to the concept “coffee”. Particular actions ortypes of actions may be assigned a higher weight and/or rating thanother actions, which may affect the overall calculated coefficient. Asan example and not by way of limitation, if a first user emails a seconduser, the weight or the rating for the action may be higher than if thefirst user simply views the user-profile page for the second user.

In particular embodiments, social-networking system 160 may calculate acoefficient based on the type of relationship between particularobjects. Referencing the social graph 200, social-networking system 160may analyze the number and/or type of edges 206 connecting particularuser nodes 202 and concept nodes 204 when calculating a coefficient. Asan example and not by way of limitation, user nodes 202 that areconnected by a spouse-type edge (representing that the two users aremarried) may be assigned a higher coefficient than a user nodes 202 thatare connected by a friend-type edge. In other words, depending upon theweights assigned to the actions and relationships for the particularuser, the overall affinity may be determined to be higher for contentabout the user's spouse than for content about the user's friend. Inparticular embodiments, the relationships a user has with another objectmay affect the weights and/or the ratings of the user's actions withrespect to calculating the coefficient for that object. As an exampleand not by way of limitation, if a user is tagged in first photo, butmerely likes a second photo, social-networking system 160 may determinethat the user has a higher coefficient with respect to the first photothan the second photo because having a tagged-in-type relationship withcontent may be assigned a higher weight and/or rating than having alike-type relationship with content. In particular embodiments,social-networking system 160 may calculate a coefficient for a firstuser based on the relationship one or more second users have with aparticular object. In other words, the connections and coefficientsother users have with an object may affect the first user's coefficientfor the object. As an example and not by way of limitation, if a firstuser is connected to or has a high coefficient for one or more secondusers, and those second users are connected to or have a highcoefficient for a particular object, social-networking system 160 maydetermine that the first user should also have a relatively highcoefficient for the particular object. In particular embodiments, thecoefficient may be based on the degree of separation between particularobjects. The lower coefficient may represent the decreasing likelihoodthat the first user will share an interest in content objects of theuser that is indirectly connected to the first user in the social graph200. As an example and not by way of limitation, social-graph entitiesthat are closer in the social graph 200 (i.e., fewer degrees ofseparation) may have a higher coefficient than entities that are furtherapart in the social graph 200.

In particular embodiments, social-networking system 160 may calculate acoefficient based on location information. Objects that aregeographically closer to each other may be considered to be more relatedor of more interest to each other than more distant objects. Inparticular embodiments, the coefficient of a user towards a particularobject may be based on the proximity of the object's location to acurrent location associated with the user (or the location of a clientsystem 130 of the user). A first user may be more interested in otherusers or concepts that are closer to the first user. As an example andnot by way of limitation, if a user is one mile from an airport and twomiles from a gas station, social-networking system 160 may determinethat the user has a higher coefficient for the airport than the gasstation based on the proximity of the airport to the user.

In particular embodiments, social-networking system 160 may performparticular actions with respect to a user based on coefficientinformation. Coefficients may be used to predict whether a user willperform a particular action based on the user's interest in the action.A coefficient may be used when generating or presenting any type ofobjects to a user, such as advertisements, search results, news stories,media, messages, notifications, or other suitable objects. Thecoefficient may also be utilized to rank and order such objects, asappropriate. In this way, social-networking system 160 may provideinformation that is relevant to user's interests and currentcircumstances, increasing the likelihood that they will find suchinformation of interest. In particular embodiments, social-networkingsystem 160 may generate content based on coefficient information.Content objects may be provided or selected based on coefficientsspecific to a user. As an example and not by way of limitation, thecoefficient may be used to generate media for the user, where the usermay be presented with media for which the user has a high overallcoefficient with respect to the media object. As another example and notby way of limitation, the coefficient may be used to generateadvertisements for the user, where the user may be presented withadvertisements for which the user has a high overall coefficient withrespect to the advertised object. In particular embodiments,social-networking system 160 may generate search results based oncoefficient information. Search results for a particular user may bescored or ranked based on the coefficient associated with the searchresults with respect to the querying user. As an example and not by wayof limitation, search results corresponding to objects with highercoefficients may be ranked higher on a search-results page than resultscorresponding to objects having lower coefficients.

In particular embodiments, social-networking system 160 may calculate acoefficient in response to a request for a coefficient from a particularsystem or process. To predict the likely actions a user may take (or maybe the subject of) in a given situation, any process may request acalculated coefficient for a user. The request may also include a set ofweights to use for various factors used to calculate the coefficient.This request may come from a process running on the online socialnetwork, from a third-party system 170 (e.g., via an API or othercommunication channel), or from another suitable system. In response tothe request, social-networking system 160 may calculate the coefficient(or access the coefficient information if it has previously beencalculated and stored). In particular embodiments, social-networkingsystem 160 may measure an affinity with respect to a particular process.Different processes (both internal and external to the online socialnetwork) may request a coefficient for a particular object or set ofobjects. Social-networking system 160 may provide a measure of affinitythat is relevant to the particular process that requested the measure ofaffinity. In this way, each process receives a measure of affinity thatis tailored for the different context in which the process will use themeasure of affinity.

In connection with social-graph affinity and affinity coefficients,particular embodiments may utilize one or more systems, components,elements, functions, methods, operations, or steps disclosed in U.S.patent application Ser. No. 11/503,093, filed 11 Aug. 2006, U.S. patentapplication Ser. No. 12/977,027, filed 22 Dec. 2010, U.S. patentapplication Ser. No. 12/978,265, filed 23 Dec. 2010, and U.S. patentapplication Ser. No. 13/632,869, field 1 Oct. 2012, each of which isincorporated by reference.

Systems and Methods

FIG. 7 illustrates an example computer system 700. In particularembodiments, one or more computer systems 700 perform one or more stepsof one or more methods described or illustrated herein. In particularembodiments, one or more computer systems 700 provide functionalitydescribed or illustrated herein. In particular embodiments, softwarerunning on one or more computer systems 700 performs one or more stepsof one or more methods described or illustrated herein or providesfunctionality described or illustrated herein. Particular embodimentsinclude one or more portions of one or more computer systems 700.Herein, reference to a computer system may encompass a computing device,and vice versa, where appropriate. Moreover, reference to a computersystem may encompass one or more computer systems, where appropriate.

This disclosure contemplates any suitable number of computer systems700. This disclosure contemplates computer system 700 taking anysuitable physical form. As example and not by way of limitation,computer system 700 may be an embedded computer system, a system-on-chip(SOC), a single-board computer system (SBC) (such as, for example, acomputer-on-module (COM) or system-on-module (SOM)), a desktop computersystem, a laptop or notebook computer system, an interactive kiosk, amainframe, a mesh of computer systems, a mobile telephone, a personaldigital assistant (PDA), a server, a tablet computer system, or acombination of two or more of these. Where appropriate, computer system700 may include one or more computer systems 700; be unitary ordistributed; span multiple locations; span multiple machines; spanmultiple data centers; or reside in a cloud, which may include one ormore cloud components in one or more networks. Where appropriate, one ormore computer systems 700 may perform without substantial spatial ortemporal limitation one or more steps of one or more methods describedor illustrated herein. As an example and not by way of limitation, oneor more computer systems 700 may perform in real time or in batch modeone or more steps of one or more methods described or illustratedherein. One or more computer systems 700 may perform at different timesor at different locations one or more steps of one or more methodsdescribed or illustrated herein, where appropriate.

In particular embodiments, computer system 700 includes a processor 702,memory 704, storage 706, an input/output (I/O) interface 708, acommunication interface 710, and a bus 712. Although this disclosuredescribes and illustrates a particular computer system having aparticular number of particular components in a particular arrangement,this disclosure contemplates any suitable computer system having anysuitable number of any suitable components in any suitable arrangement.

In particular embodiments, processor 702 includes hardware for executinginstructions, such as those making up a computer program. As an exampleand not by way of limitation, to execute instructions, processor 702 mayretrieve (or fetch) the instructions from an internal register, aninternal cache, memory 704, or storage 706; decode and execute them; andthen write one or more results to an internal register, an internalcache, memory 704, or storage 706. In particular embodiments, processor702 may include one or more internal caches for data, instructions, oraddresses. This disclosure contemplates processor 702 including anysuitable number of any suitable internal caches, where appropriate. Asan example and not by way of limitation, processor 702 may include oneor more instruction caches, one or more data caches, and one or moretranslation lookaside buffers (TLBs). Instructions in the instructioncaches may be copies of instructions in memory 704 or storage 706, andthe instruction caches may speed up retrieval of those instructions byprocessor 702. Data in the data caches may be copies of data in memory704 or storage 706 for instructions executing at processor 702 tooperate on; the results of previous instructions executed at processor702 for access by subsequent instructions executing at processor 702 orfor writing to memory 704 or storage 706; or other suitable data. Thedata caches may speed up read or write operations by processor 702. TheTLBs may speed up virtual-address translation for processor 702. Inparticular embodiments, processor 702 may include one or more internalregisters for data, instructions, or addresses. This disclosurecontemplates processor 702 including any suitable number of any suitableinternal registers, where appropriate. Where appropriate, processor 702may include one or more arithmetic logic units (ALUs); be a multi-coreprocessor; or include one or more processors 702. Although thisdisclosure describes and illustrates a particular processor, thisdisclosure contemplates any suitable processor.

In particular embodiments, memory 704 includes main memory for storinginstructions for processor 702 to execute or data for processor 702 tooperate on. As an example and not by way of limitation, computer system700 may load instructions from storage 706 or another source (such as,for example, another computer system 700) to memory 704. Processor 702may then load the instructions from memory 704 to an internal registeror internal cache. To execute the instructions, processor 702 mayretrieve the instructions from the internal register or internal cacheand decode them. During or after execution of the instructions,processor 702 may write one or more results (which may be intermediateor final results) to the internal register or internal cache. Processor702 may then write one or more of those results to memory 704. Inparticular embodiments, processor 702 executes only instructions in oneor more internal registers or internal caches or in memory 704 (asopposed to storage 706 or elsewhere) and operates only on data in one ormore internal registers or internal caches or in memory 704 (as opposedto storage 706 or elsewhere). One or more memory buses (which may eachinclude an address bus and a data bus) may couple processor 702 tomemory 704. Bus 712 may include one or more memory buses, as describedbelow. In particular embodiments, one or more memory management units(MMUs) reside between processor 702 and memory 704 and facilitateaccesses to memory 704 requested by processor 702. In particularembodiments, memory 704 includes random access memory (RAM). This RAMmay be volatile memory, where appropriate. Where appropriate, this RAMmay be dynamic RAM (DRAM) or static RAM (SRAM). Moreover, whereappropriate, this RAM may be single-ported or multi-ported RAM. Thisdisclosure contemplates any suitable RAM. Memory 704 may include one ormore memories 704, where appropriate. Although this disclosure describesand illustrates particular memory, this disclosure contemplates anysuitable memory.

In particular embodiments, storage 706 includes mass storage for data orinstructions. As an example and not by way of limitation, storage 706may include a hard disk drive (HDD), a floppy disk drive, flash memory,an optical disc, a magneto-optical disc, magnetic tape, or a UniversalSerial Bus (USB) drive or a combination of two or more of these. Storage706 may include removable or non-removable (or fixed) media, whereappropriate. Storage 706 may be internal or external to computer system700, where appropriate. In particular embodiments, storage 706 isnon-volatile, solid-state memory. In particular embodiments, storage 706includes read-only memory (ROM). Where appropriate, this ROM may bemask-programmed ROM, programmable ROM (PROM), erasable PROM (EPROM),electrically erasable PROM (EEPROM), electrically alterable ROM (EAROM),or flash memory or a combination of two or more of these. Thisdisclosure contemplates mass storage 706 taking any suitable physicalform. Storage 706 may include one or more storage control unitsfacilitating communication between processor 702 and storage 706, whereappropriate. Where appropriate, storage 706 may include one or morestorages 706. Although this disclosure describes and illustratesparticular storage, this disclosure contemplates any suitable storage.

In particular embodiments, I/O interface 708 includes hardware,software, or both, providing one or more interfaces for communicationbetween computer system 700 and one or more I/O devices. Computer system700 may include one or more of these I/O devices, where appropriate. Oneor more of these I/O devices may enable communication between a personand computer system 700. As an example and not by way of limitation, anI/O device may include a keyboard, keypad, microphone, monitor, mouse,printer, scanner, speaker, still camera, stylus, tablet, touch screen,trackball, video camera, another suitable I/O device or a combination oftwo or more of these. An I/O device may include one or more sensors.This disclosure contemplates any suitable I/O devices and any suitableI/O interfaces 708 for them. Where appropriate, I/O interface 708 mayinclude one or more device or software drivers enabling processor 702 todrive one or more of these I/O devices. I/O interface 708 may includeone or more I/O interfaces 708, where appropriate. Although thisdisclosure describes and illustrates a particular I/O interface, thisdisclosure contemplates any suitable I/O interface.

In particular embodiments, communication interface 710 includeshardware, software, or both providing one or more interfaces forcommunication (such as, for example, packet-based communication) betweencomputer system 700 and one or more other computer systems 700 or one ormore networks. As an example and not by way of limitation, communicationinterface 710 may include a network interface controller (NIC) ornetwork adapter for communicating with an Ethernet or other wire-basednetwork or a wireless NIC (WNIC) or wireless adapter for communicatingwith a wireless network, such as a WI-FI network. This disclosurecontemplates any suitable network and any suitable communicationinterface 710 for it. As an example and not by way of limitation,computer system 700 may communicate with an ad hoc network, a personalarea network (PAN), a local area network (LAN), a wide area network(WAN), a metropolitan area network (MAN), or one or more portions of theInternet or a combination of two or more of these. One or more portionsof one or more of these networks may be wired or wireless. As anexample, computer system 700 may communicate with a wireless PAN (WPAN)(such as, for example, a BLUETOOTH WPAN), a WI-FI network, a WI-MAXnetwork, a cellular telephone network (such as, for example, a GlobalSystem for Mobile Communications (GSM) network), or other suitablewireless network or a combination of two or more of these. Computersystem 700 may include any suitable communication interface 710 for anyof these networks, where appropriate. Communication interface 710 mayinclude one or more communication interfaces 710, where appropriate.Although this disclosure describes and illustrates a particularcommunication interface, this disclosure contemplates any suitablecommunication interface.

In particular embodiments, bus 712 includes hardware, software, or bothcoupling components of computer system 700 to each other. As an exampleand not by way of limitation, bus 712 may include an AcceleratedGraphics Port (AGP) or other graphics bus, an Enhanced Industry StandardArchitecture (EISA) bus, a front-side bus (FSB), a HYPERTRANSPORT (HT)interconnect, an Industry Standard Architecture (ISA) bus, an INFINIBANDinterconnect, a low-pin-count (LPC) bus, a memory bus, a Micro ChannelArchitecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, aPCI-Express (PCIe) bus, a serial advanced technology attachment (SATA)bus, a Video Electronics Standards Association local (VLB) bus, oranother suitable bus or a combination of two or more of these. Bus 712may include one or more buses 712, where appropriate. Although thisdisclosure describes and illustrates a particular bus, this disclosurecontemplates any suitable bus or interconnect.

Herein, a computer-readable non-transitory storage medium or media mayinclude one or more semiconductor-based or other integrated circuits(ICs) (such, as for example, field-programmable gate arrays (FPGAs) orapplication-specific ICs (ASICs)), hard disk drives (HDDs), hybrid harddrives (HHDs), optical discs, optical disc drives (ODDs),magneto-optical discs, magneto-optical drives, floppy diskettes, floppydisk drives (FDDs), magnetic tapes, solid-state drives (SSDs),RAM-drives, SECURE DIGITAL cards or drives, any other suitablecomputer-readable non-transitory storage media, or any suitablecombination of two or more of these, where appropriate. Acomputer-readable non-transitory storage medium may be volatile,non-volatile, or a combination of volatile and non-volatile, whereappropriate.

Miscellaneous

Herein, “or” is inclusive and not exclusive, unless expressly indicatedotherwise or indicated otherwise by context. Therefore, herein, “A or B”means “A, B, or both,” unless expressly indicated otherwise or indicatedotherwise by context. Moreover, “and” is both joint and several, unlessexpressly indicated otherwise or indicated otherwise by context.Therefore, herein, “A and B” means “A and B, jointly or severally,”unless expressly indicated otherwise or indicated otherwise by context.

The scope of this disclosure encompasses all changes, substitutions,variations, alterations, and modifications to the example embodimentsdescribed or illustrated herein that a person having ordinary skill inthe art would comprehend. The scope of this disclosure is not limited tothe example embodiments described or illustrated herein. Moreover,although this disclosure describes and illustrates respectiveembodiments herein as including particular components, elements,functions, operations, or steps, any of these embodiments may includeany combination or permutation of any of the components, elements,functions, operations, or steps described or illustrated anywhere hereinthat a person having ordinary skill in the art would comprehend.Furthermore, reference in the appended claims to an apparatus or systemor a component of an apparatus or system being adapted to, arranged to,capable of, configured to, enabled to, operable to, or operative toperform a particular function encompasses that apparatus, system,component, whether or not it or that particular function is activated,turned on, or unlocked, as long as that apparatus, system, or componentis so adapted, arranged, capable, configured, enabled, operable, oroperative.

What is claimed is:
 1. A method comprising, by a computing system:receiving, from a client system, a query inputted by a first user at asearch client, the search client being associated with context data froma page associated with the search client, wherein the context dataidentifies: a type of the page associated with the search client, asocial context of the page associated with the search client, and athreshold number of search results for display; identifying one or moreentities matching the query; ranking each of the identified entitiesbased at least in part on the type of the page associated with thesearch client and the social context of the page associated with thesearch client; and sending, to the client system, instructions forpresenting a search-results interface comprising the threshold number ofsearch results corresponding to the threshold number of top rankingidentified entities.
 2. The method of claim 1, wherein the socialcontext identifies social data from an online social network associatedwith the page associated with the search client.
 3. The method of claim1, wherein the social context identifies one or more of: one or moretags associated with the page, one or more comments associated with thepage, one or more likes associated with the page, one or more sharesassociated with the page, one or more commenters associated with thepage, one or more owners associated with the page, or any combinationthereof.
 4. The method of claim 1, wherein the context data identifies atype of search relevant to the type of the page associated with thesearch client.
 5. The method of claim 4, wherein the type of search is atypeahead search or a graph search.
 6. The method of claim 1, whereinthe context data identifies one or more of: web suggestions from asearch engine, current location of the first user, speed of movement ofthe first user, direction of movement of the first user, or anycombination thereof.
 7. The method of claim 1, wherein identifying oneor more entities matching the query comprises: generating a querycommand based at least in part on the received query and the contextdata from the page associated with the search client; and retrieving,from one or more data stores of an online social network, one or morereferences to the one or more entities corresponding to the querycommand, respectively.
 8. The method of claim 1, wherein ranking each ofthe identified entities is further based at least in part on one or morebinary factors associated with the context data and a weighting of oneor more of the binary factors.
 9. The method of claim 1, wherein theinstructions for presenting a search-results interface are generatedbased at least in part on the context data of the page associated withthe search client.
 10. The method of claim 1, wherein one or more of thesearch results is a suggested query comprising a reference to one ormore entities.
 11. The method of claim 1, wherein the query is inputtedby the first user as a character string comprising one or morecharacters into a graphical user interface of the client system, thegraphical user interface comprising a query field of a nativeapplication associated with an online social network or a webpage of anonline social network accessed by a browser client.
 12. The method ofclaim 1, wherein the query is associated with one of tagging,commenting, or sharing content associated with an online social network.13. The method of claim 1, wherein the query is associated with datareferencing one or more friends of an owner of a digital imageassociated with the query, interested users of the digital image, orusers tagged in the digital image.
 14. The method of claim 1, furthercomprising accessing a social graph comprising a plurality of nodes anda plurality of edges connecting the nodes, each of the edges between twoof the nodes representing a single degree of separation between them,the plurality of nodes comprising: a first node corresponding to thefirst user; and a plurality of second nodes corresponding to a pluralityof entities associated with an online social network, respectively. 15.The method of claim 14, wherein ranking each of the identified entitiesis further based at least in part on a social-graph affinity of thefirst node with the second node corresponding to the identified entity.16. The method of claim 14, wherein the context data further identifiesone or more second nodes, of the plurality of second nodes, associatedwith the page.
 17. The method of claim 14, wherein the page associatedwith the search client corresponds to a particular node of the pluralityof second nodes, and wherein the context data comprises informationidentifying one or more second nodes, of the plurality of second nodes,connected by an edge to the particular node corresponding to the page ofthe search client.
 18. The method of claim 14, wherein one or more ofthe search results is a suggested structured query comprising referencesto one or more edges and one or more nodes.
 19. One or morecomputer-readable non-transitory storage media embodying software thatis operable when executed to: receive, from a client system, a queryinputted by a first user at a search client, the search client beingassociated with context data from a page associated with the searchclient, wherein the context data identifies: a type of the pageassociated with the search client, a social context of the pageassociated with the search client, and a threshold number of searchresults for display; identify one or more entities matching the query;rank each of the identified entities based at least in part on the typeof the page associated with the search client and the social context ofthe page associated with the search client; and send, to the clientsystem, instructions for presenting a search-results interfacecomprising the threshold number of search results corresponding to thethreshold number of top ranking identified entities.
 20. A systemcomprising: one or more processors; and a memory coupled to theprocessors comprising instructions executable by the processors, theprocessors operable when executing the instructions to: receive, from aclient system, a query inputted by a first user at a search client, thesearch client being associated with context data from a page associatedwith the search client, wherein the context data identifies: a type ofthe page associated with the search client, a social context of the pageassociated with the search client, and a threshold number of searchresults for display; identify one or more entities matching the query;rank each of the identified entities based at least in part on the typeof the page associated with the search client and the social context ofthe page associated with the search client; and send, to the clientsystem, instructions for presenting a search-results interfacecomprising the threshold number of search results corresponding to thethreshold number of top ranking identified entities.